package com.mark.web.data.entity.vo;

import com.mark.web.data.entity.po.Category;
import com.mark.common.utils.DateTimeUtil;
import com.mark.common.utils.PropertiesUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @Description: 商品种类VO封装
 * @Author: Mark
 * @CreateDate: 2018/5/10.
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CategoryVo {

    /**
     * 主键id
     */
    private Integer id;

    /**
     * 种类所属的店铺id
     */
    private Integer shopId;

    /**
     * 所属父类id
     */
    private Integer parentId;

    /**
     * 种类名称
     */
    private String productCategoryName;

    /**
     * 类别状态：1-正常,2-已废弃
     */
    private Boolean enableStatus;

    /**
     * 图片地址
     */
    private String imageAddress;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String lastEditTime;

    /**
     * 主机地址
     */
    private String imageHost;

    public CategoryVo(Category category){
        this.id = category.getId();
        this.shopId = category.getShopId();
        this.parentId = category.getParentId();
        this.productCategoryName = category.getProductCategoryName();
        this.enableStatus = category.getEnableStatus();
        this.imageAddress = category.getImageAddress();
        this.createTime = DateTimeUtil.dateToStr2(category.getCreateTime());
        this.lastEditTime = DateTimeUtil.dateToStr2(category.getLastEditTime());
        this.imageHost = PropertiesUtil.getProperty("ftp.server.http.prefix", PropertiesUtil.FTP_SERVER_HTTP_PREFIX);
    }

    public CategoryVo assembleCategoryVo(Category category){
        CategoryVo categoryVo = new CategoryVo();
        categoryVo.setId(category.getId());
        categoryVo.setShopId(category.getShopId());
        categoryVo.setParentId(category.getParentId());
        categoryVo.setProductCategoryName(category.getProductCategoryName());
        categoryVo.setEnableStatus(category.getEnableStatus());
        categoryVo.setImageAddress(category.getImageAddress());
        categoryVo.setCreateTime(DateTimeUtil.dateToStr2(category.getCreateTime()));
        categoryVo.setLastEditTime(DateTimeUtil.dateToStr2(category.getLastEditTime()));
        categoryVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix",PropertiesUtil.FTP_SERVER_HTTP_PREFIX));
        return categoryVo;
    }
}
